package dao.mapper.auth;

import model.auth.Users;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mybatis.spring.annotation.Mapper;

@Mapper("auth.UsersCrudMapper")
public interface UsersCrudMapper {

	@Select("select seq_a_users.nextval from dual")
	long selectKey();
	
	@Insert("insert into a_users (id, account, password, realname, enabled, issys, userdesc) values " +
			" (#{m.id}, #{m.account}, #{m.password:VARCHAR}, #{m.realName:VARCHAR}, #{m.enabled:INTEGER}, #{m.issys:INTEGER}, #{m.userDesc:VARCHAR})")
	int insert(@Param("m") Users model);
	
	@Select("select * from a_users where id=#{id} ")
	Users getById(@Param("id") Long id);

	@Select("select * from a_users where id=#{id} and enabled=#{enabled}")
	Users getValidById(@Param("id") Long id, @Param("enabled") Integer enabled);
	
	@Delete("delete from a_users where id=#{id}")
	int deleteById(@Param("id") Long id);
}
